package com.ericsson.rm.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.Root;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.ericsson.rm.model.ResourceDetail;
import com.ericsson.rm.model.ResourceSkillDetail;

@Repository
public class ResourceDetaiIDaoImpl implements ResourceDetailDao{
	
	@Autowired
	EntityManagerFactory factory;
	
	@SuppressWarnings("unchecked")
	public List<String> fetchById(String resourceId) {
		EntityManager entity = factory.createEntityManager();
		Query q = entity.createNamedQuery("ResourceDetail.findById" , ResourceDetail.class);
		return q.getResultList();
	}

	@Override
	public List<ResourceDetail> findResourceByJobStageAndSkillId() {
	/*
	 * select r1.firstName,r1.secondName,r1.signum,r1.lineManagerSignum,r1.emailId,r1.phoneNo from resourceDetail r1,
	 * resourceSkillDetail r2 where r1.resourceId=r2.resourceId and r1.jobStage=:jobStage and r2.skillId=:skillId
	 * 
	 * 
	 * 
	  */
	EntityManager entity = factory.createEntityManager();	
	CriteriaBuilder cb = entity.getCriteriaBuilder();
	CriteriaQuery<ResourceDetail> cq = cb.createQuery(ResourceDetail.class);
	Root<ResourceDetail> resourceDetail = cq.from(ResourceDetail.class);
	Root<ResourceSkillDetail> ResourceSkillDetail = cq.from(ResourceSkillDetail.class);
	//Join<ResourceDetail,ResourceSkillDetail> joinResourSkill = resourceDetail.join(collection)
		
		return null;
	}

	



}
